import java.util.Arrays;
import java.util.Scanner;

/**
 * 输入n个整数，输出其中最小的k个
 */
public class HJ58 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            int[] ints = new int[n];
            for (int i = 0; i < n; i++) {
                ints[i] = scanner.nextInt();
            }
            Arrays.sort(ints);

            for (int i = 0; i < k; i++) {
                System.out.print(ints[i]+" ");
            }
        }
    }
}
